package lib.user;

import lib.operation.*;

import java.util.Scanner;



//普通用户
public class OrdinaryPerson extends User{

    //构造方法
    public OrdinaryPerson(String name){
        super(name);

        this.aDo = new Do[]{
                new Borrow(),          //0,借阅
                new Select(),          //1,查询一条数据
                new ReturnBook(),      //2,还书
                new Exit()             //3,退出系统
        };
    }

    //重写父类User的menu方法
    @Override
    public int menu() {
        System.out.println("==普通用户菜单==");

        System.out.println("=================================");
        System.out.println("hello, " + this.name + "欢迎使用湖工大图书馆管理系统");
        System.out.println("0.借阅图书");
        System.out.println("1.查找图书");
        System.out.println("2.归还图书");
        System.out.println("3.退出系统");
        System.out.println("================================");
        System.out.println("请按照提示选择相应操作: ");
        Scanner sc = new Scanner(System.in);
        int choice = sc.nextInt();
        if (choice == 1 || choice ==2 || choice == 3||choice == 0){
            return choice;
        }else{
            System.out.println("请输入正确的数字");
            //递归
            return menu();
        }
    }
}
